import { Observable } from 'rxjs';
import { RequestService } from './request.service';
import { Injectable } from '@angular/core';
import {  TaskParam } from '../model/task';
import { HttpParams } from '@angular/common/http';

@Injectable()
export class TaskApiService {

  baseUrl = '/task';
  constructor(
    private request: RequestService,
  ) { }

  public listBeginBetween(begin: Date, end: Date): Observable<Array<TaskParam>> {
    const url = this.baseUrl + '/beginIn';
    const param = new HttpParams(
      { fromObject: { begin: begin.toISOString(), end: end.toISOString() } }
    );
    return this.request.get(url, param);
  }

  public listEndBetween(begin: Date, end: Date): Observable<Array<TaskParam>> {
    const url = this.baseUrl + '/endIn';
    const param = new HttpParams(
      { fromObject: { begin: begin.toISOString(), end: end.toISOString() } }
    );
    return this.request.get(url, param);
  }



}
